<template>
  <a-modal
    :visible="visible"
    title="新增问题"
    cancelText="取消"
    okText="保存"
    width="60%"
    @ok="submit"
    @cancel="cancel"
  >
    <a-form
      ref="formRef"
      :model="modelForm.data"
      :rules="formRules"
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >
      <a-row>
        <a-col :span="8">
          <a-form-item label="问题名" name="name">
            <!-- <a-textarea v-model:value="modelForm.data.name" placeholder="请输入内容" :rows="1" /> -->
            <a-input v-model:value="modelForm.data.name" />
          </a-form-item>
          <a-form-item>
            <span style="margin-left: 30px">
              *新增评价仅适用于未结课的课程
            </span>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </a-modal>
</template>
<script>
import { message } from 'ant-design-vue';
import { defineComponent, reactive, ref, toRaw } from "vue";
export default defineComponent({
  props: {
    visible: {
      type: Boolean,
    },
  },
  emit: ["close"],
  setup(props, context) {

    const formRef = ref();

    const formState = reactive({
      name: '',
    });

    const modelForm = reactive({
      data: {
        content: ''
      }
    })

    const formRules = {
      name: [ { required: true, message: '请输入问题名', trigger: 'blur'} ],
    };

    const saveKey = "save";

    const submit = (e) => {
      message.loading({ content: '提交中...', key: saveKey });
      console.log(e, 'e')
    };

    const cancel = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };

    const openDialog = (type) => {
      formState[type] = true
    }

    const closeDialog = (type) => {
      formState[type] = false
    }

    const selectUniversity = (value) => {
      console.log(value, 'value')
    }

    const selectCharge = () => {

    }

    return {
      submit,
      cancel,
      formRef,
      formState,
      modelForm,
      formRules,
      selectUniversity,
      selectCharge,
      openDialog,
      closeDialog,

      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    };
  },
});
</script>
